namespace CIS
{
    using CISLib;
    using System;
    using System.ComponentModel;
    using System.Web;

    public class Global : HttpApplication
    {
        private IContainer components = null;

        public Global()
        {
            this.InitializeComponent();
        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            HttpApplication application = (HttpApplication) sender;
            HttpContext context = application.Context;
            if (context.Request.IsAuthenticated)
            {
                string userName = context.User.Identity.Name;
                SysUser sysUser = null;
                if (sysUser == null)
                {
                    sysUser = ManageUser.GetUserViaName(userName);
                }
                if (sysUser == null)
                {
                    throw new ApplicationException("Not a legal user.");
                }
                UserPrincipal principal = new UserPrincipal(sysUser, base.Context.User.Identity);
                context.User = principal;
            }
        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
        }

        protected void Application_End(object sender, EventArgs e)
        {
        }

        protected void Application_EndRequest(object sender, EventArgs e)
        {
        }

        protected void Application_Error(object sender, EventArgs e)
        {
        }

        protected void Application_Start(object sender, EventArgs e)
        {
        }

        private void InitializeComponent()
        {
            this.components = new Container();
        }

        protected void Session_End(object sender, EventArgs e)
        {
        }

        protected void Session_Start(object sender, EventArgs e)
        {
        }
    }
}

